import axios from "axios";

const instance = axios.create({
	baseURL:'https://www.fastmock.site/mock/5f464b959a7b9645d62b1f1bdf18c4c2/jd',
	timeout:10000
})

export const get = (url, params={}) => {
	return new Promise((resolve, reject)=>{
		instance.get(url, {params}).then((response)=>{
			resolve(response.data)
		}, err=>{
			reject(err)
		})
	})
}

export const post = (url, data={}) => {
	return new Promise((resolve, reject)=>{
		instance.post(url, data, {
			headers:{
				'Content-Type': 'application/json'
			}
		}).then((response)=>{
			resolve(response.data)
		}, err=>{
			reject(err)
		})
	})
}